﻿using System.Globalization;
using System.Windows;
using System.Windows.Media;

namespace FAQ_UI
{
	internal class TextDrawable : Drawable
	{
		private string mText;
		private double mTextSize;
		private Typeface mTypeface;

		public TextDrawable() : this("")
		{
		}

		public TextDrawable(string text) : this(text, 12)
		{
		}

		public TextDrawable(string text, double textSize) : this(text, textSize, new Typeface("Arial"))
		{
		}

		public TextDrawable(string text, double textSize, Typeface typeface)
		{
			Text = text;
			TextSize = textSize;
			Typeface = typeface;
		}

		public string Text
		{ get { return mText; } set { mText = value; invalidateSelf(); } }
		public double TextSize
		{ get { return mTextSize; } set { mTextSize = value; invalidateSelf(); } }
		public Typeface Typeface
		{ get { return mTypeface; } set { mTypeface = value; invalidateSelf(); } }

		public override void draw(DrawingContext dc)
		{
			if (mText == null) return;
			FormattedText t = new FormattedText(mText, CultureInfo.InvariantCulture, FlowDirection.LeftToRight, mTypeface, mTextSize, Theme.AccentBrush, 96);
			dc.DrawText(t, new System.Windows.Point(bounds.X, bounds.Y));
		}
	}
}